Page({
  data: {
    "imgUrls": ['https://ytq.oss-cn-beijing.aliyuncs.com/file/9d15effcbcae3cd1c358b98b97786cecc687c5b4.png',
      'https://ytq.oss-cn-beijing.aliyuncs.com/file/25eeeda562f5eaaa85a44ea71907b4979ce875e1.png',
      'https://ytq.oss-cn-beijing.aliyuncs.com/file/18f076221a495bc54d851f70640fdb5b86fc5cd0.png'],
    "shops":[{"picture":"/static/images/home.png"}, {"picture":"/static/images/order.png"}, {"picture":"/static/images/my.png"}]
  },

  onLoad: function () {
   
  } ,

  onShow:function(){
    var that = this;
    wx.request({
      url: getApp().globalData.hostIp+"/shop/selectAll",
        success(res) {
          console.log(res.data.data.rows)
          var shops = res.data.data.rows;
          that.setData({
            shops: shops
          })
        }
      })
  
  },
  //weui
  showInput() {
    this.setData({
      inputShowed: true
    });
  },
  hideInput() {
    this.setData({
      inputVal: "",
      inputShowed: false
    });
    // this.loadMainGoods();
  },
  clearInput() {
    this.setData({
      inputVal: ""
    });
    // this.loadMainGoods();
  },

  // 获取搜索的值
  inputTyping(e) {
    this.setData({
      inputVal: e.detail.value
    });
    this.search(e);
  },

  // 搜索
  // search(e) {
  //   console.log("触发了search事件");

  //   wx.request({
  //     url: getApp().globalData.hostIp + '/goods/selectByShopIds',
  //     method: "GET",
  //     data: {
  //       search: e.detail.value,
  //       shelfFlag: 1,
  //       pageNum: 1,
  //       pageSize: that.data.pageSize,
  //       schoolId: wx.getStorageSync('schoolId')
  //     },
  //     success: (res) => {
  //       console.log("success调用服务器findBookdataList方法");
  //       console.log(res);
  //       that.setData({
  //         goods: res.data.list,
  //         pageNum: 1,
  //         addGoods: []
  //       });
  //     },
  //     fail: (res) => {
  //       console.log("fail");
  //     }
  //   });
  // },

  showDetail(e){
    var index = e.currentTarget.dataset.index;
    var shop = this.data.shops[index]
    console.log(shop)
    wx.navigateTo({
      url: "/pages/index/shop/shop?shop=" + JSON.stringify(shop)
    })
  }
  
})
